#include <bits/stdc++.h>
using namespace std;
int cnt = 0;
main(){
	for (int i = 1; i <= 5; i++){
		char a, b, c, d;
		cin >> a >> b >> c >> d;
		if ((a == c) && (b == d - 1)){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}